package com.uenpay.im.ui.old.activity.red;

import com.qiyunxin.android.http.net.HttpInvokeItem;
import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 红包答谢
 * 
 * @author SL
 * 
 */
public class ReturnThanksRedInvokItem extends HttpInvokeItem {

	public class ReturnThanksRedInvokItemResult extends HttpInvokeResult {
		public String packetsid;
	}

	public ReturnThanksRedInvokItemResult getOutput() {
		return (ReturnThanksRedInvokItemResult) GetResultObject();
	}

	/**
	 * 答谢红包
	 * 
	 * @param packetsid
	 * @param thankswords
	 */
	public ReturnThanksRedInvokItem(String packetsid, String thankswords) {
		String url = APIConfiguration.getBaseUrl()
				+ "Purse/RedPackets/returnThanks?packetsid=" + packetsid
				+ "&thankswords=" + thankswords + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		ReturnThanksRedInvokItemResult result = new ReturnThanksRedInvokItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");
		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}

		return result;
	}

}
